// myNOD.cpp : Defines the entry pounsigned int for the console application.
//

#include "stdafx.h"

#include <iostream>
#include <time.h>   
#include <ctime>




using namespace std;


///////////////////////// RECURSIBE NOD //////////////////////////
unsigned int nod(unsigned int x, unsigned int y){
	if (y == 0)
		return x;
	return nod(y, x % y);
}
///////////////////////// RECURSIBE NOD //////////////////////////

unsigned int nodMinus(unsigned int a, unsigned int b) {
	while (a != b) {
		if (a > b) a -= b;
		else b -= a;
	}
	return a;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////
unsigned int k = 0;


unsigned int nodMy(unsigned int a, unsigned int b)

{
	if (a >= b)
	{
		k = b;
	}
	else
	{
		k = a;
	}

	if (a % 2 == 0 && b % 2 == 0)
	{

		while (a%k != 0 || b%k != 0)
		{
			k = k - 2;
		}
	}
	else
	{
		if (a % 5 == 0 && b % 5 == 0)
		{
			while (a%k != 0 || b%k != 0)
			{
				k = k - 5
					;
			}
		}
		else
		{
			while (a%k != 0 || b%k != 0)
			{
				k = k - 1;
			}
		}
	}
	return(k);

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////








 int main()
{
	clock_t start;
	clock_t end;


	unsigned int testArray[] = {242343243,34324234234,432432423,434324234,21321321,31232
		
		,42343242442,42343242343244
		
		
		,0 };

	unsigned int a, b;
	//cout << "Enter a,b\n";
	
	
	///c//in >> a;
/////	cin >> b;


	unsigned int size,i=0;

	while (testArray[i])
	{
		size = testArray[i];
		a = testArray[i];
		b = testArray[i+1];

		cout << "///////// A= " << a;
		cout << "    ///////// B= " << b;
		cout << "\n";

		start = clock();
		cout << "NOD with divide:    " << nod(a, b) << "     Output";
		end = clock();
		cout << "TIME: " << (end - start) / CLOCKS_PER_SEC << "\n";

		start = clock();
		cout << "Nod with minus:    " << nodMinus(a, b) << "     Output";
		end = clock();
		cout << "TIME: " << (end - start) / CLOCKS_PER_SEC << "\n";

		start = clock();
		cout << "Nod my:    " << nodMy(a, b) << "     Output";
		end = clock();
		cout << "TIME: " << (end - start) / CLOCKS_PER_SEC << "\n";
		i +=2;



	}



}



